package com.xmg.day08;

import lombok.extern.slf4j.Slf4j;

/**
 * @Author: mazhongqing
 * @Date: 2020/11/3 14:53
 */
@Slf4j(topic = "m.topic")
public class TeaDemo {
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{

            try {
                log.debug("洗水壶");
                Thread.sleep(1000);
                log.debug("烧开水");
                Thread.sleep(5000);
                Thread.currentThread().wait();
                log.debug("泡茶");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        },"老王");

        Thread t2 = new Thread(()->{
            try{
                log.debug("洗茶壶");
                Thread.sleep(1000);
                log.debug("洗茶杯");
                Thread.sleep(2000);
                log.debug("拿茶叶");
                Thread.sleep(1000);
                t1.notify();
                //log.debug("泡茶");
             }catch (Exception e){
                e.printStackTrace();
            }
        },"小王");

        t1.start();
        t2.start();
    }
}
